Skip to content

feat(tool): print message receipt size and event size in forest-tool archive info#6821

Merged
hanabi1224 merged 2 commits intomainfrom
hm/tracking-receipt-event-size-in-archive-info
Mar 30, 2026
Merged

feat(tool): print message receipt size and event size in forest-tool archive info#6821
hanabi1224 merged 2 commits intomainfrom
hm/tracking-receipt-event-size-in-archive-info

Conversation

@hanabi1224
Copy link
Copy Markdown
Contributor

@hanabi1224 hanabi1224 commented Mar 30, 2026

Summary of changes

❯ forest-tool archive info lite_2000_5881637.forest.car.zst
CAR format:       ForestCARv1.zst
Snapshot version: 1
Network:          mainnet
Epoch:            5881637
State-roots:      2000
Messages sets:    2000
Receipts:         32145
Receipts size:    1.4 MiB
Events:           78323
Events size:      14 MiB
Head Tipset:      bafy2bzaceczzxkwgk57humvkuvmrdcaofjmyqq73rdpuox4oo5qzliabgbhd2
                  bafy2bzacecdkeuaizhozax2w2xzw36oaaoldcuglwoyxyrzrvssgd2roqli7e
                  bafy2bzacea4lzsq6bw7nndrjveemixa7j5qnrkhfr6tqva4ky3tvhobgt57g6
                  bafy2bzacebkgc26qitf7rhjn5a2coega7aegshtnc6i5konfglg6dfolvf6k4
Index size:       1.91 GiB
❯ forest-tool archive info lite_2000_3580931.forest.car.zst
CAR format:       ForestCARv1.zst
Snapshot version: 1
Network:          calibnet
Epoch:            3580931
State-roots:      2000
Messages sets:    2000
Receipts:         49662
Receipts size:    3 MiB
Events:           70489
Events size:      19.6 MiB
Head Tipset:      bafy2bzaceb3mmhd7nzfr6iybwtx7yskpca4khenx6w4swd6aii5er7jxj2ml2
                  bafy2bzacecbc4kdarzogsylixrzxq5hoo7j73b4n25nivbdmshlq5zvq55dlo
                  bafy2bzaceacjm5kyd6ye43ssvg3wprgxnbjvowwlagwzt3dcl6zu6qcqpkr4y
Index size:       356.8 MiB

Changes introduced in this pull request:

Reference issue to close (if applicable)

Closes

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • New Features
    • The forest-tool archive info command now reports message receipt size and event size metrics in addition to existing output.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 30, 2026

Walkthrough

The changes add size metrics tracking for receipts and events in archive information. A new public method for computing blockstore byte size is added to MemoryDB, and archive command logic is enhanced with fields and read-operation tracking to measure and display these sizes.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added entry documenting new receipt size and event size metrics in forest-tool archive info output.
MemoryDB Enhancement
src/db/memory.rs
Added public method blockstore_size_bytes() that calculates total byte size of blockstores by summing CID and value lengths across both blockchain maps.
Archive Metrics & Tracking
src/tool/subcommands/archive_cmd.rs
Extended ArchiveInfo with message_receipts_size and events_size fields. Receipt and event fetching now use ReadOpsTrackingStore wrappers to measure blockstore read sizes. Renamed receipt counter variable and updated display labels.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • akaladarshi
  • sudo-shashank
  • LesnyRumcajs
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main feature: adding message receipt size and event size printing to the forest-tool archive info output.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hm/tracking-receipt-event-size-in-archive-info
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch hm/tracking-receipt-event-size-in-archive-info

Comment @coderabbitai help to get the list of available commands and usage tips.

@hanabi1224 hanabi1224 marked this pull request as ready for review March 30, 2026 11:58
@hanabi1224 hanabi1224 requested a review from a team as a code owner March 30, 2026 11:58
@hanabi1224 hanabi1224 requested review from akaladarshi and sudo-shashank and removed request for a team March 30, 2026 11:58
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/db/memory.rs (1)

27-34: Add rustdoc for the new public method.

blockstore_size_bytes is a public API and should have a short doc comment describing what bytes are included (CID bytes + block bytes, both maps).

Suggested patch
 impl MemoryDB {
+    /// Returns the total byte size of blocks stored in memory, including
+    /// both CID key bytes and block payload bytes across ephemeral and
+    /// persistent block maps.
     pub fn blockstore_size_bytes(&self) -> usize {
         self.blockchain_db
             .read()
             .iter()
             .chain(self.blockchain_persistent_db.read().iter())
             .map(|(k, v)| k.to_bytes().len() + v.len())
             .sum()
     }
As per coding guidelines: "Document public functions and structs with doc comments".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/db/memory.rs` around lines 27 - 34, Add a Rust doc comment to the public
method blockstore_size_bytes describing what it returns and what bytes are
counted: state that it returns the total size in bytes of both in-memory maps
(blockchain_db and blockchain_persistent_db), summing each entry's CID key bytes
(k.to_bytes().len()) plus the block value bytes (v.len()), and clarify that both
maps are included. Place the doc comment immediately above the pub fn
blockstore_size_bytes(&self) signature.
src/tool/subcommands/archive_cmd.rs (1)

315-317: Add a regression test for the new size fields in ArchiveInfo output.

Since CLI text now includes Receipts size and Events size, a focused test asserting these lines exist (and remain formatted) would make this safer against future refactors.

Also applies to: 331-342

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/tool/subcommands/archive_cmd.rs` around lines 315 - 317, Add a regression
test that verifies the CLI text output for ArchiveInfo includes the new size
lines: assert the output contains properly formatted "Receipts size" and "Events
size" lines tied to the ArchiveInfo fields message_receipts_size and
events_size; locate where ArchiveInfo is rendered (the Display impl or the
function that formats archive output used by the archive subcommand) and write a
test that constructs an ArchiveInfo with known message_receipts_size/events_size
(and counts) and asserts the generated string contains the exact labeled lines
(e.g., "Receipts size:" and "Events size:") so future refactors won't remove or
reformat them.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/db/memory.rs`:
- Around line 27-34: Add a Rust doc comment to the public method
blockstore_size_bytes describing what it returns and what bytes are counted:
state that it returns the total size in bytes of both in-memory maps
(blockchain_db and blockchain_persistent_db), summing each entry's CID key bytes
(k.to_bytes().len()) plus the block value bytes (v.len()), and clarify that both
maps are included. Place the doc comment immediately above the pub fn
blockstore_size_bytes(&self) signature.

In `@src/tool/subcommands/archive_cmd.rs`:
- Around line 315-317: Add a regression test that verifies the CLI text output
for ArchiveInfo includes the new size lines: assert the output contains properly
formatted "Receipts size" and "Events size" lines tied to the ArchiveInfo fields
message_receipts_size and events_size; locate where ArchiveInfo is rendered (the
Display impl or the function that formats archive output used by the archive
subcommand) and write a test that constructs an ArchiveInfo with known
message_receipts_size/events_size (and counts) and asserts the generated string
contains the exact labeled lines (e.g., "Receipts size:" and "Events size:") so
future refactors won't remove or reformat them.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8c65b8cd-0415-40f8-b1c4-23e63b0dc570

📥 Commits

Reviewing files that changed from the base of the PR and between 73f9afb and 9994e75.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/db/memory.rs
  • src/tool/subcommands/archive_cmd.rs

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 30, 2026

Codecov Report

❌ Patch coverage is 59.25926% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.85%. Comparing base (73f9afb) to head (9994e75).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/tool/subcommands/archive_cmd.rs 42.10% 11 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/db/memory.rs 90.22% <100.00%> (+0.62%) ⬆️
src/tool/subcommands/archive_cmd.rs 29.58% <42.10%> (+0.01%) ⬆️

... and 9 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73f9afb...9994e75. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hanabi1224 hanabi1224 added this pull request to the merge queue Mar 30, 2026
Merged via the queue into main with commit c28557b Mar 30, 2026
44 checks passed
@hanabi1224 hanabi1224 deleted the hm/tracking-receipt-event-size-in-archive-info branch March 30, 2026 13:20
sudo-shashank pushed a commit that referenced this pull request Mar 31, 2026
@coderabbitai coderabbitai Bot mentioned this pull request Apr 1, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants